package visual;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JPanel;

import main.GameDef;

public class Board extends JPanel implements MouseListener, GameDef{
	public Player player;
	
	public Board(){
		addMouseListener(this);
	}
	
	public void paint(Graphics g){
		g.setColor(new Color(0x000000));
		g.fillRect(0, 0, BOARD_WIDTH, BOARD_HEIGHT);
		g.setColor(new Color(0xFFFFFF));
		for(int i = 0; i < BOARD_PIECES_Y; i++){
			g.drawLine(0, i * BLOCK_HEIGHT, BOARD_WIDTH, i * BLOCK_HEIGHT);
		}
		for(int i = 0; i < BOARD_PIECES_X; i++){
			g.drawLine(i * BLOCK_WIDTH, 0, i * BLOCK_WIDTH, BOARD_HEIGHT);
		}
	}
	
	public Dimension getPreferredSize(){
		return new Dimension(BLOCK_WIDTH * BOARD_WIDTH, BLOCK_WIDTH * BOARD_WIDTH);
	}
	
	public Dimension getMaximumSize(){
		return getPreferredSize();
	}
	
	public Dimension getMinimumSize(){
		return getPreferredSize();
	}
	
	public void setPlayer(Player p){
		player = p;
	}
	
	public void mouseClicked(MouseEvent e) {
		if(FrameHandler.hasToBuyPiece){
			if(e.getButton() == e.BUTTON1){
				FrameHandler.hasToBuyPiece = false;	
			}
		}
	}

	public void mouseEntered(MouseEvent e) {
	}

	public void mouseExited(MouseEvent e) {
	}

	public void mousePressed(MouseEvent e) {
	}

	public void mouseReleased(MouseEvent e) {
	}
}
